package com.zdj.aoplibrary.aspect;

import com.zdj.aoplibrary.annotations.DebugTrace;
import com.zdj.aoplibrary.util.DebugLog;
import com.zdj.aoplibrary.util.StopWatch;
import com.zdj.utils.LogLevel;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;

/**
 * Created by dengjie on 2016/01/08.
 */
@Aspect
public class DBAspect {
    /**
     * 使用该注解的所有方法中使用{@link #DB_METHOD}逻辑 <br/>
     * modify by dengjie at 2016/01/08 21:32
     */
    private static final String DB_METHOD =
            "execution(@com.zdj.aoplibrary.annotations.DBClose * *(..))";

    @Pointcut(DB_METHOD)
    public void methodAnnotatedWithDebugTrace() {
    }

    @Around("methodAnnotatedWithDebugTrace()")
    public Object weaveJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable {
        Object result = joinPoint.proceed();
        MethodSignature methodSignature = (MethodSignature)joinPoint.getSignature();
        methodSignature.getMethod().invoke(joinPoint,new Object[]{});
        return result;
    }
}
